package com.adams.audit.config;

import java.util.List;

import junit.framework.Assert;
import junit.framework.TestCase;

import com.adams.access.db.bean.AuditStep;
import com.adams.audit.config.service.IAuditStepService;
import com.adams.audit.web.bean.AuditType;
import com.adams.utils.AppContext;

public class AuditStepServiceTestBean extends TestCase
{
	private static IAuditStepService auditStepService;

	static
	{
		AppContext.load("applicationContext-test.xml");
		auditStepService = (IAuditStepService) AppContext
				.getBean("auditStepService");
	}

	public void testUpdateAuditStepForType()
	{

		List<AuditStep> list1 = auditStepService.listAllStepsByType("aaaaaa");
		List<AuditStep> list2 = auditStepService.listAllStepsByType("article");
		auditStepService.updateAuditStepForType(list1);
		for (AuditStep auditStep : list2)
		{
			auditStep.setId(null);
		}
		auditStepService.updateAuditStepForType(list2);
	}

	public void testSaveAuditStepForType()
	{

		List<AuditStep> list1 = auditStepService.listAllStepsByType("aaaaaa");
		List<AuditStep> list2 = auditStepService.listAllStepsByType("article");
		auditStepService.saveAuditStepForType(list1);
		for (AuditStep auditStep : list2)
		{
			auditStep.setId(null);
		}
		auditStepService.saveAuditStepForType(list2);
	}

	public void testListAllStepsByType()
	{
		auditStepService.listAllStepsByType("article");
	}

	public void testCreateStepNo()
	{
		List<String> list = auditStepService.createStepNo(10);
		Assert.assertEquals(10, list.size());
	}

	public void testGetAllType()
	{
		List<AuditType> list = auditStepService.getAllType();
		Assert.assertEquals(3, list.size());
	}
}
